home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / ndp.zip / NDP_TYPE.DOC < prev    next >
Text File  |  1987-08-02  |  6KB  |  138 lines

  1.      /*
  2.                                   NDP_TYPE.DOC
  3.  
  4.      NOTE:    All  of  the  Coprocessor logic, detection and typing, in the
  5.      enclosed  files  are the copyrighted work of Ted Forgeron as presented
  6.      in  his  article  in  PC  Tech Journal, Aug 87, p 43.  The limit of my
  7.      contribution  to  this  effort is in the development of the C language
  8.      interface and the examples.                       Pat Shea/Psi! 080187
  9.  
  10.      This archive should contain six [6] files, as follows:
  11.  
  12.          (1)  NDP_TYPE.ASM  -- the source code to produce a linkable object
  13.               file  [for  use  with  Microsoft  C] containing ndp_type(), a
  14.               function  which  reports  the  presence  and type of NDP in a
  15.               system  at  runtime.   Since there are no data passed to this
  16.               function  when  called,  and  only  1 byte coming back to the
  17.               caller,  I  have elected to pass this byte in AL as the func-
  18.               tion's  return code.  With very minor modification, this code
  19.               can  be used to produce a linkable object for other languages
  20.               such  as  Fortran  or  PASCAL, or it can be incorporated into
  21.               other ASM programs.
  22.  
  23.          (2)  NDP_TYPE.DOC -- this file that you are now reading.  In addi-
  24.               tion  to  being  the  documentation for this archive, it is a
  25.               compilable C language program [see TEST_IT.EXE below].
  26.  
  27.          (3)  NDP_TYPE.OBJ  -- what you get when you assemble NDP_TYPE.ASM.
  28.               It  contains   ndp_type(),  the function that does all of the
  29.               work  described  below in the TEST_NDP.ASM description and is
  30.               callable  from  MSC.  Presently, this function is set for the
  31.               Small Memory model.
  32.  
  33.                    Calling:          int ndp_type( void );
  34.  
  35.                    Returns:          0 if NO CHIP is found
  36.                                      1 if an 8087 is found
  37.                                      2 if an 80287
  38.                                  and 3 for an 80387
  39.  
  40.          (4)  TEST_IT.EXE  -- what you get when you compile/link this docu-
  41.               ment as follows:
  42.  
  43.                    MSC   ndp_type.doc, test_it;  [NOTE:  name change !!]
  44.  
  45.                    LINK   test_it + ndp_type;
  46.  
  47.  
  48.               The  file  that you end up with, TEST_IT.EXE does exactly the
  49.               same  thing  that  TEST_NDP.COM  does but is C language based
  50.               and  calls  the  assembler  function, ndp_type() contained in
  51.               the  enclosed OBJ file to do all of the work for it.  A quick
  52.               review  of  the  C  source code below will show that the only
  53.               things  that  I  am  doing  in C are interpreting the results
  54.               from   ndp_type(),  some  string handling and putting data on
  55.               the screen.
  56.  
  57.          (5)  TEST_NDP.ASM  --  source code for an executable program which
  58.               detects  the  presence  of  an NDP [Numeric Data Processor or
  59.               Math  Coprocessor]  in  an  Intel 8086 based computer running
  60.               under  DOS  [version  independent].  Additionally, it reports
  61.               the type of NDP present - 8087, 80287 or 80387.
  62.  
  63.          (6)  TEST_NDP.COM  --  the  executable  program  produced from the
  64.               above source code via MASM /R --> LINK --> EXE2BIN.
  65.  
  66.      COMMENTS:
  67.  
  68.          The  function,  ndp_type(),  has  been tested on an IBM XT mod 089
  69.          containing  and  Intel 8087, an IBM AT mod 339 with an Intel 80287
  70.          and  a  COMPAQ  386 with no Coprocessor.  It seems to do its thing
  71.          correctly.   Unfortunately, I do not have access to a machine with
  72.          an  80387  as  yet  so that part of the logic must remain untested
  73.          for the time.
  74.  
  75.          These  files  are  the  product  of a nocturnal hack brought on by
  76.          reading  some  interesting  code  in  PCTJ.  Feel free to comment,
  77.          ridicule,  modify, improve, use or discard as you see fit.  Howev-
  78.          er, if changes to the function, ndp_type() are distributed, please
  79.          carry   forward   Ted  Forgeron's  copyright  information  on  the
  80.          coprocessor logic.
  81.  
  82.                                      enjoy!!
  83.                                      Pat Shea, AJ3B /Psi!
  84.                                      [76210,712]
  85.      */
  86.  
  87. #include    <stdio.h>
  88. #include    <string.h>
  89. #include    <stdlib.h>
  90.  
  91. int ndp_type( void );  /* This is the function that duz the work.
  92.                           Everything else is standard library stuff
  93.                           and is declared in the #include's.       */
  94. main()
  95. {
  96.     int numb;
  97.     char str[26];
  98.  
  99.     putchar( '\n' );
  100.     puts( "Checking for a Math Coprocessor...." );
  101.     putchar( '\n' );
  102.  
  103.     strcpy( str, "I see " );
  104.  
  105.     numb = ndp_type();   /* This is where we pick up the return
  106.                             value so that we can determine the
  107.                             type of NDP present, if any.
  108.    
  109.    NOTE:  If Ur not interested in the specific type NDP that is
  110.           present and only want to find out if one is available,
  111.           just test for a nonzero return value from ndp_type().
  112.           However, if your return value is >3, something is VERY
  113.           wrong !!                                               */
  114.  
  115.     switch ( numb )
  116.     {
  117.         case 0:
  118.             strcat( str, "NO CHIP " );
  119.             break;
  120.         case 1:
  121.             strcat( str, "an 8087 " );
  122.             break;
  123.         case 2:
  124.             strcat( str, "an 80287 " );
  125.             break;
  126.         case 3:
  127.             strcat( str, "an 80387 " );
  128.             break;
  129.         default:
  130.             puts( "Abandon Ship!" );
  131.             exit( 0 );
  132.     }
  133.     strcat( str, "in here !!" );
  134.     puts( str );
  135.     putchar( '\n' );
  136.     return( 0 );
  137. }           /*   */
  138.